<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
//         function runP1(){
//     const p1=new Promise(r=>console.log('立即打印'))
//     return p1
// }

function runAsync(x){
const p=new Promise(resolve=>setTimeout(()=>resolve(x,console.log(x)),1000*x))
return p
}
// runAsync(1)
// .then(data=>{
//     console.log(data)
// })

// Promise.all   并发执行
Promise.all([runAsync(3),runAsync(1),runAsync(2),])
// 等所有的Promise fullfiled 才会then
// 保持promise 顺序来返回结果
.then(res=>console.log(res))
    </script>
</body>
</html>